home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
redakcyjne
/
programy
/
Tlen 6.0.1.12 pl
/
tleninst60112.exe
/
sdk
/
Plugin_src
/
options-vc
/
demoplugin.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2006-09-18
|
4KB
|
177 lines
// demoplugin.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "../../TlenSources/plugin/plugin_struct.h"
#include "../../TlenSources/plugin/plugin_options.h"
#include "AggressiveOptimize.h"
HINSTANCE hInst;
TLENPLUGINFUNCTIONS *tlen_functions;
HWND option_window = NULL;
HBITMAP icon1, icon2;
COLORREF bgColor;
HBRUSH hBrush;
TLENPLUGININFO pluginInfo={
sizeof(TLENPLUGININFO),
"Obs│uga opcji - VC++",
PLUGIN_API_VERSION,
MAKE_DWORD_VERSION(1,2,3,4),
"Opis pluginu",
"⌐ Prawa autorskie",
"Producent",
"E@mail",
"http://www",
0,
0,
0,
0
};
extern "C" __declspec(dllexport) TLENPLUGININFO* GetPluginInfo(DWORD TlenVersion);
extern "C" __declspec(dllexport) int LoadPlugin(TLENPLUGINFUNCTIONS *tlen_functions);
extern "C" __declspec(dllexport) int UnloadPlugin(void);
int prefDialog(HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam)
{
switch (message) {
case WM_INITDIALOG:
{
hBrush=::CreateSolidBrush(bgColor);
break;
}
case WM_ERASEBKGND:
{
RECT rc;
::GetClientRect(hWnd, &rc);
HDC hdc= (HDC) wparam;
FillRect(hdc,&rc,hBrush);
return true;
}
case WM_CTLCOLORSTATIC:
{
RECT rc;
HWND hnd = (HWND) lparam;
::GetClientRect(hnd, &rc);
HDC hdc= (HDC) wparam;
SetTextColor(hdc, RGB(0,0,0));
SetBkColor(hdc, bgColor);
return (int) hBrush;
}
case WM_DESTROY:
{
DeleteObject(hBrush);
break;
}
}
return 0;
}
static int OptionPageClicked(WPARAM wParam, LPARAM lParam)
{
TlenOptionPageShowInfo *info = (TlenOptionPageShowInfo *) wParam;
strcpy(info->Caption, "Przyk│adowa nazwa zak│adki");
strcpy(info->Description, "To jest opis zak│adki, tutaj mo┐na wstawiµ d│u┐szy tekst, aby wyja£niµ u┐ytkownikowi, co siΩ tu dzieje.");
switch (info->Action)
{
case TLEN_OPTIONS_PAGE_ACTION_SHOW:
{
if (!option_window)
{
bgColor = info->bgColor;
option_window = CreateDialog(hInst, MAKEINTRESOURCE(101), info->Handle, (DLGPROC)prefDialog);
tlen_functions->CallTlenFunction(hInst, TLEN_ADD_DIALOG_HANDLE, (WPARAM) option_window, NULL);
}
info->Icon = icon1;
info->Flags |= TLEN_OPTIONS_PAGEINFO_FLAG_ICONTRANS;
SetWindowPos(option_window, 0, info->x, info->y, info->width, info->height, SWP_NOSIZE | SWP_NOZORDER);
ShowWindow(option_window, SW_SHOW);
break;
}
case TLEN_OPTIONS_PAGE_ACTION_HIDE:
{
if (option_window) ShowWindow(option_window, SW_HIDE);
break;
}
case TLEN_OPTIONS_PAGE_ACTION_OK:
case TLEN_OPTIONS_PAGE_ACTION_APPLY:
{
//KlikniΩto ok lub zastosuj, wiΩc przetwarzamy tutaj opcje wybrane przez u┐ytkownika
if (info->Action == TLEN_OPTIONS_PAGE_ACTION_APPLY) break;
}
case TLEN_OPTIONS_PAGE_ACTION_CANCEL:
{
if (option_window)
{
tlen_functions->CallTlenFunction(hInst, TLEN_REMOVE_DIALOG_HANDLE, (WPARAM) option_window, NULL);
DestroyWindow(option_window);
option_window = NULL;
break;
}
}
}
return 0;
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
hInst=hinstDLL;
return TRUE;
}
__declspec(dllexport) TLENPLUGININFO* GetPluginInfo(DWORD tlenVersion)
{
return &pluginInfo;
}
__declspec(dllexport) int LoadPlugin(TLENPLUGINFUNCTIONS *functions)
{
icon1 = (HBITMAP) LoadImage(hInst, MAKEINTRESOURCE(104),IMAGE_BITMAP, 32, 32, NULL);
icon2 = (HBITMAP) LoadImage(hInst, MAKEINTRESOURCE(105),IMAGE_BITMAP, 16, 16, NULL);
tlen_functions = functions;
TlenOptionPageDefinition def;
InitializeStruct(def);
def.CallBack = OptionPageClicked;
def.ID = "BasicPluginVC/Page1";
def.Caption = "Dodatkowa zak│adka 1";
def.Icon = icon2;
def.Flags = TLEN_OPTIONS_PAGEDEF_FLAG_TLENCOLOR | TLEN_OPTIONS_PAGEDEF_FLAG_ICONTRANS;
tlen_functions->CallTlenFunction(hInst, TLEN_ADD_OPTIONS_PAGE, (WPARAM) hInst, (LPARAM) &def);
return 0;
}
__declspec(dllexport) int UnloadPlugin(void)
{
if (option_window)
{
tlen_functions->CallTlenFunction(hInst, TLEN_REMOVE_DIALOG_HANDLE, (WPARAM) option_window, NULL);
DestroyWindow(option_window);
}
DeleteObject(icon1);
DeleteObject(icon2);
return 0;
}